<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />
		<title>一汽集团人口与计划生育信息管理系统</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="js/common.js"></script>

		<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(resource/images/login_1/log_bg.jpg);
	background-repeat: repeat-x;
}

a:link {
	color: #AA5007;
}

a:visited {
	color: #AA5007;
}

a:hover {
	color: #FF0000;
}

a:active {
	color: #003399;
}

body,td,th {
	font-size: 14px;
	color: #333333;
}
-->
</style>
<script type="text/javascript">
	$(function() {
		$('input:text:first').focus(); //把焦点放在第一个文本框	

		$("#user_name").blur(
			function() {
				var org_list_jsonObj = {
					"classname" : "com.wxtf.platform.plugins.user.UserLoginAction",
					"methodname" : "listOrg",
					"extenddata" : []
				};
				var username = $("#user_name").attr("value").trim();
				if (username == '') {
					return;
				}
				org_list_jsonObj.extenddata = "[{\"userName\":\"" + username + "\"}]";
				callserver(org_list_jsonObj,
					function(data) {
						var html = document.getElementById("org_select");
						var org_se = $("#org_select");
						org_se.empty();
						for ( var i = 0; i < data.resultrecord.length; i++) {
							var option = $("<option>").text(data.resultrecord[i].caption).val(data.resultrecord[i].department_id);
							org_se.append(option);
						}
					}, function() {}
				);
			});

		$("#user_name").keypress(function(e) {
			var e = e || window.event;
			var keyCode = e.keyCode || e.which;
			if (keyCode == 13) {
				document.getElementById('user_passwd').focus();
			}
		});
		$("#user_passwd").keypress(function(e) {
			var e = e || window.event;
			var keyCode = e.keyCode || e.which;
			if (keyCode == 13) {
				document.getElementById('org_select').focus();
			}
		});
		$("#org_select").keypress(function(e) {
			var e = e || window.event;
			var keyCode = e.keyCode || e.which;
			if (keyCode == 13) {
				document.getElementById('vercode').focus();
			}
		});
		$("#vercode").keypress(function(e) {
			var e = e || window.event;
			var keyCode = e.keyCode || e.which;
			if (keyCode == 13) {
				login_all();
			}
		});

	});

	//登录按钮
	function login_all() {
		var userName = $("#user_name").attr("value").trim();
		var userPasswd = $("#user_passwd").attr("value").trim();
		var nowOrgan = $("#org_select").attr("value");
		var verCode = $("#vercode").attr("value").trim();

		if (userName == '') {
			document.getElementById("errorMsg").innerHTML = "用户名：不能为空";
			return;
		}
		if (userPasswd == '') {
			document.getElementById("errorMsg").innerHTML = "密码：不能为空";
			return;
		}
		if (nowOrgan == '') {
			document.getElementById("errorMsg").innerHTML = "机构：不能为空";
			return;
		}
		if(verCode == ''){
			document.getElementById("errorMsg").innerHTML="验证码：不能为空";
			return;
		}
		var jsonObj = {
			"classname" : "com.wxtf.platform.plugins.user.UserLoginAction",
			"methodname" : "userLogic",
			"extenddata" : "[{\"userName\":\"" + userName
					+ "\",\"passWord\":\"" + userPasswd + "\",\"nowOrgan\":\""
					+ nowOrgan + "\",\"verCode\":\"" + verCode + "\"}]"
		};
		callserver(jsonObj, successReadResult, errorReadResult);
	}
	function reset(){
		$("#user_name").val("");
		$("#user_passwd").val("");
		$("#org_select").val("");
		$("#vercode").val("");
		$("#errorMsg").html("");
	}

	
	//登录使用
	function successReadResult(data, textStatus) {
		if (data.resultmessage == "sucess") {
			if(document.all){
				window.location.href = "<%=path%>/jsp/sys/"+ data.resultrecord.userlay;
			} else {
				window.location.href = "jsp/sys/" + data.resultrecord.userlay;
			}
		} else if (data.resultmessage == "error") {
			document.getElementById("errorMsg").innerHTML = '用户名或密码错误！请重试！';
			document.getElementById('vcode').src = 'jsp/sys/image.jsp?' + Math.random();
		} else {
			document.getElementById("errorMsg").innerHTML = data.resultrecord.message;
			document.getElementById('vcode').src = 'jsp/sys/image.jsp?' + Math.random();
		}
	}

	function errorReadResult(data, textStatus) {
		document.getElementById("errorMsg").innerHTML = "登录失败，请联系管理员";
	}
</script>
	</head>
	<body>
		<div id="center" style="position: absolute;top: 40px;left: 100px;z-index: 1;width: 630px;height: 558px;">
			<table width="630" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="630" height="432" align="left" valign="top" background="resource/images/login_1/log_main_bg.jpg">
						<table width="630" height="418" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td width="350">&nbsp;</td>
								<td height="120" colspan="2"></td>
							</tr>
							<tr>
								<td width="350">&nbsp;</td>
								<td height="26" colspan="2">
									<span id="errorMsg" style="margin-left20px; font-weight: bold; color: red;"></span>
								</td>
							</tr>
							<tr>
								<td>&nbsp;</td>
								<td width="71" height="32" align="right">
									<label>用户名：</label>
								</td>
								<td width="209" align="left">
									<input type="text" style="width: 150px; border: #999999 1px solid" id="user_name" name="user_name"/>
								</td>
							</tr>
							<tr>
								<td>&nbsp;</td>
								<td height="32" align="right">
									<label>密 码：&nbsp;</label>
								</td>
								<td height="32" align="left">
									<input type="password" style="width: 150px; border: #999999 1px solid" id="user_passwd" name="user_passwd"/>
								</td>
							</tr>
							<tr>
								<td>&nbsp;</td>
								<td height="31" align="right">部门名称：</td>
								<td height="31" align="left">
									<select name="org_select" id="org_select" style="width: 153px; border: #999999 1px solid">
									</select>
								</td>
							</tr>
							<tr>
								<td rowspan="2">&nbsp;</td>
								<td height="39" align="right">验证码：</td>
								<td height="39">
									<table style=" margin-left: -3px;">
										<tr>
											<td><input type="text" style="width: 85px; border: #999999 1px solid;" name="vercode" id="vercode" /></td>
											<td>
												<img src="jsp/sys/image.jsp" title="看不清楚?点击刷新！" id="vcode" alt="点击刷新！"
													style="cursor: pointer; " onClick="vcode.src='jsp/sys/image.jsp?'+Math.random()" />
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td colspan="2" align="center">
									<img src="resource/images/login_1/btn_1.jpg" width="93" height="30" border="0" onclick="login_all();" style=" cursor: pointer;"/>&nbsp;&nbsp;
									<img src="resource/images/login_1/btn_2.jpg" width="93" height="30" border="0" onclick="reset();" style=" cursor: pointer;"/>
								</td>
							</tr>
							<tr>
								<td height="70">&nbsp;</td>
								<td height="70" colspan="2">
									<div style="margin-left: 90px; color: #AA5007">
										<a href="#" onclick="window.open('http://www.firefox.com.cn');return false;">火狐浏览器下载</a>
									</div>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td width="630" height="125">
						<img src="resource/images/login_1/log_main_down.png" width="630" height="125" />
					</td>
				</tr>
			</table>

		</div>
		<script type="text/javascript">
			var W = document.documentElement.clientWidth;
			var H = document.documentElement.clientHeight;

			var offWidth = (W - 630)/2;
			if(offWidth > 0){
				document.getElementById('center').style.left = offWidth + "px";
			}else{
				document.getElementById('center').style.left = W + "px";
			}
			var offHeight = (H - 558)/2;
			if(offHeight > 0){
				document.getElementById('center').style.top = offHeight + "px";
			}else{
				document.getElementById('center').style.top = "20px";
			}
			
		</script>
	</body>
</html>


